﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
using WP.Modules;
using WP.Commons;
namespace MaxLeaf
{
    partial class frmAbout : BaseQryRpt 
    {
        public frmAbout()
        {
            InitializeComponent();
            this.mblnNeedSaveStartPositionInfo = false;
            this.Text = "大枫集团PDM";
            
            string userRoot = "HKEY_LOCAL_MACHINE";
            string subkey = "SOFTWARE\\MaxLeaf\\MaxLeafPDM";
            string keyName = userRoot + "\\" + subkey;
            object objKeyValue = Microsoft.Win32.Registry.GetValue(keyName, "COMPANYNAME", "");
            if (objKeyValue == null)
            {
                subkey = "SOFTWARE\\MaxLeaf\\MaxLeafPDM";
                keyName = userRoot + "\\" + subkey;
                objKeyValue = Microsoft.Win32.Registry.GetValue(keyName, "COMPANYNAME", "");
            }


            string strCompanyName = objKeyValue == null ? "" : objKeyValue.ToString();
            lblUserComp.Text = strCompanyName;
            objKeyValue = Microsoft.Win32.Registry.GetValue(keyName, "USERNAME", "");
            string strUserName = objKeyValue == null ? "" : objKeyValue.ToString();
            lblUser.Text = strUserName;
            objKeyValue = Microsoft.Win32.Registry.GetValue(keyName, "VERSION", "");
            string strVersion = objKeyValue == null ? "" : objKeyValue.ToString();
            objKeyValue = Microsoft.Win32.Registry.GetValue(keyName, "COMPILEDATE", "");
            string strCompileDate = objKeyValue == null ? "" : objKeyValue.ToString();
            lblVersion.Text = "Version: " + strVersion + " (" + strCompileDate +")";

            string strProductDetail = "本系统为大枫集团PDM系统";

            string strDeclaimer = "Warning:This computer program is protected by copyright Law " +
                                    "and international treaties. Unauthorized reproduction or distribution " +
                                    "of this program,or any portion of it,may result in severe civil and criminal " +
                                    "penalties,and will be prosecuted to the maximum extent possible under the law.";
            txtProductDetail.Text = strProductDetail;
            lblWarning.Text = strDeclaimer;

            this.picNuPro.Visible = Customize.IsNuPro();
            this.picWoodpro.Visible = !Customize.IsNuPro();


        }

        #region 程序集属性访问器

        public string AssemblyTitle
        {
            get
            {
                // 获取此程序集上的所有 Title 属性
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                // 如果至少有一个 Title 属性
                if (attributes.Length > 0)
                {
                    // 请选择第一个属性
                    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                    // 如果该属性为非空字符串，则将其返回
                    if (titleAttribute.Title != "")
                        return titleAttribute.Title;
                }
                // 如果没有 Title 属性，或者 Title 属性为一个空字符串，则返回 .exe 的名称
                return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }

        public string AssemblyVersion
        {
            get
            {
                return Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }

        public string AssemblyDescription
        {
            get
            {
                // 获取此程序集的所有 Description 属性
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                // 如果 Description 属性不存在，则返回一个空字符串
                if (attributes.Length == 0)
                    return "";
                // 如果有 Description 属性，则返回该属性的值
                return ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }
        }

        public string AssemblyProduct
        {
            get
            {
                // 获取此程序集上的所有 Product 属性
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                // 如果 Product 属性不存在，则返回一个空字符串
                if (attributes.Length == 0)
                    return "";
                // 如果有 Product 属性，则返回该属性的值
                return ((AssemblyProductAttribute)attributes[0]).Product;
            }
        }

        public string AssemblyCopyright
        {
            get
            {
                // 获取此程序集上的所有 Copyright 属性
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                // 如果 Copyright 属性不存在，则返回一个空字符串
                if (attributes.Length == 0)
                    return "";
                // 如果有 Copyright 属性，则返回该属性的值
                return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }
        }

        public string AssemblyCompany
        {
            get
            {
                // 获取此程序集上的所有 Company 属性
                object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                // 如果 Company 属性不存在，则返回一个空字符串
                if (attributes.Length == 0)
                    return "";
                // 如果有 Company 属性，则返回该属性的值
                return ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }
        #endregion
    }
}
